package com.lhy.mymall.config;

import com.lhy.mymall.common.Constant;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: 卢辉宇
 * @date: 2022/12/17 13:05
 * @description: 地址映射类
 */
@Configuration
public class MallWebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //将请求路径为/img/**的通通映射到自定义常量类的对应地址
        registry.addResourceHandler("/img/**").addResourceLocations("file:"+Constant.FILE_UPLOAD_DIR);
        registry.addResourceHandler("/qrcode/**").addResourceLocations("file:"+Constant.FILE_QRCODE_DIR);
    }
}
